package com.homedo.async.mysql.support.mapper.select;

import com.homedo.async.mysql.support.mapper.MapperI;
import io.vertx.sqlclient.SqlConnection;
import org.reactivestreams.Publisher;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

/**
 * @author jgshun
 * @date 2020/3/17 10:38 AM
 */
public interface SelectMapperI<T, ID> extends MapperI<T, ID> {

    Mono<T> findById(ID id);

    Mono<T> findById(Publisher<ID> id);

    Mono<Boolean> existsById(ID id);

    Mono<Boolean> existsById(Publisher<ID> id);

    Flux<T> findAll();

    Flux<T> findByRecordSelective(T entity);

    Flux<T> findByRecordSelective(Publisher<? extends T> entityStream);

    Flux<T> findByRecordsSelective(Iterable<? extends T> entities);

    Flux<T> findByRecordsSelective(Publisher<? extends T> entityStream);

    Flux<T> findByRecord(T entity);

    Flux<T> findByRecord(Publisher<? extends T> entityStream);

    Flux<T> findByRecords(Iterable<? extends T> entities);

    Flux<T> findByRecords(Publisher<? extends T> entityStream);

    Flux<T> findByIds(Iterable<ID> ids);

    Flux<T> findByIds(Publisher<ID> idStream);

    Mono<Long> countAll();

    Mono<Long> countByRecordSelective(T entity);

    Mono<Long> countByRecordSelective(Publisher<? extends T> entityStream);

    Mono<Long> countByRecord(T entity);

    Mono<Long> countByRecord(Publisher<? extends T> entityStream);

    Mono<Long> countByRecordsSelective(Iterable<? extends T> entities);

    Mono<Long> countByRecordsSelective(Publisher<? extends T> entityStream);

    Mono<Long> countByRecords(Iterable<? extends T> entities);

    Mono<Long> countByRecords(Publisher<? extends T> entityStream);


    //=== 传入 Connection 是为了统一获得事务能力

    Mono<T> findById(ID id, SqlConnection connection);

    Mono<T> findById(Publisher<ID> id, SqlConnection connection);

    Mono<Boolean> existsById(ID id, SqlConnection connection);

    Mono<Boolean> existsById(Publisher<ID> id, SqlConnection connection);

    Flux<T> findAll(SqlConnection connection);

    Flux<T> findByRecordSelective(T entity, SqlConnection connection);

    Flux<T> findByRecordSelective(Publisher<? extends T> entity, SqlConnection connection);

    Flux<T> findByRecordsSelective(Iterable<? extends T> entities, SqlConnection connection);

    Flux<T> findByRecordsSelective(Publisher<? extends T> entityStream, SqlConnection connection);

    Flux<T> findByRecord(T entity, SqlConnection connection);

    Flux<T> findByRecord(Publisher<? extends T> entity, SqlConnection connection);

    Flux<T> findByRecords(Iterable<? extends T> entities, SqlConnection connection);

    Flux<T> findByRecords(Publisher<? extends T> entityStream, SqlConnection connection);

    Flux<T> findByIds(Iterable<ID> ids, SqlConnection connection);

    Flux<T> findByIds(Publisher<ID> idStream, SqlConnection connection);

    Mono<Long> countAll(SqlConnection connection);

    Mono<Long> countByRecordSelective(T entity, SqlConnection connection);

    Mono<Long> countByRecordSelective(Publisher<? extends T> entityStream, SqlConnection connection);

    Mono<Long> countByRecord(T entity, SqlConnection connection);

    Mono<Long> countByRecord(Publisher<? extends T> entityStream, SqlConnection connection);

    Mono<Long> countByRecordsSelective(Iterable<? extends T> entities, SqlConnection connection);

    Mono<Long> countByRecordsSelective(Publisher<? extends T> entityStream, SqlConnection connection);

    Mono<Long> countByRecords(Iterable<? extends T> entities, SqlConnection connection);

    Mono<Long> countByRecords(Publisher<? extends T> entityStream, SqlConnection connection);


}
